import { createRouter, createWebHashHistory, RouteRecordRaw, RouteLocationNormalized } from 'vue-router'

export const routes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login/login.vue'),
    meta: { hidden: true, name: '登录', enName: 'loginPage' }
  },
  {
    path: '/',
    name: 'Layouts',
    redirect: '/home',
    component: () => import('../views/layouts/layout.vue'),
    meta: { hidden: false },
    children: [
      {
        path: 'home',
        name: 'Home',
        component: () => import('../views/home/home.vue'),
        meta: { icon: 'iconshouye', hidden: false, name: '首页', enName: 'homePage' }
      }
    ]
  },
  {
    path: '/404',
    name: 'Error404',
    component: () => import('../views/error/404.vue'),
    meta: { hidden: true, name: '404', enName: 'errorPage' }
  },
]

const router = createRouter({
  history: createWebHashHistory("/vue-antd-admin/"),
  routes,
  scrollBehavior(to: RouteLocationNormalized, from: RouteLocationNormalized, _savedPosition) {
    // always scroll to top
    return { top: 0 }
  },
})

export default router
